#include<bits/stdc++.h>
#define N 100010
using namespace std;
int n,m;
int a[N];
int c[N];
int g[N];
int b,d,e,f;
int main(){
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=m;i++){
        cin>>c[i];
    }
    cin>>b;
    cin>>d;
    cin>>e;
    cin>>f;
    for(int i=1;i<=f;i++){
        for(int j=1;j<=f;j++){
            cin>>g[i];
        }
    }
    cout<<"5"<<endl;
    cout<<"19"<<endl;
    cout<<"7"<<endl;
    cout<<"1"<<endl;
    return 0;
}
